/**
 * Copyright (c) 2016 Lenovo Group
 * All Rights Reserved.
 * 
 * Project Name:app-gateway
 * Create Time: 2016年1月27日 下午2:28:01
 */
package com.lenovo.lmrp.server.appgateway.util;

import com.lenovo.lmrp.base.ParamNameDef;
import com.lenovo.sdc.framework.mq.AMQClient;
import com.lenovo.sdc.framework.mq.MQFactory;
import com.lenovo.sdc.framework.mq.MQServerParam;
import com.lenovo.sdc.framework.mq.MQServerParam.MQProvider;
import com.lenovo.sdc.framework.util.AttributeBean;

/**
 * @author zhangzhenga
 *
 */
public class AppMQClient {

    private static AMQClient mqClient;

    /**
     * 
     */
    public AppMQClient(AttributeBean attributes) {
        String host = attributes.getAttribute(ParamNameDef.MQ_SERVER_HOST, "127.0.0.1");
        int port = attributes.getAttribute(ParamNameDef.MQ_SERVER_PORT, 5566);
        MQServerParam param = new MQServerParam(MQProvider.valueOf(attributes.getAttribute(ParamNameDef.MQ_SERVER_TYPE, MQProvider.ZEROMQ.name())),host,port);
        MQFactory factory = new MQFactory(param);
        mqClient = factory.createMQClient();
    }
    
    public static AMQClient getMQClient(){
        return mqClient;
    }
}
